<!DOCTYPE html>
<html>
<!--
Copyright 2006 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.events.EventTarget</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.events.Listenable');
  goog.require('goog.events.eventTargetTester');
  goog.require('goog.events.eventTargetTester.KeyType');
  goog.require('goog.events.eventTargetTester.UnlistenReturnType');
  goog.require('goog.events.EventTarget');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>
function setUp() {
  var newListenableFn = function() {
    return new goog.events.EventTarget();
  };
  var listenFn = function(src, type, listener, opt_capt, opt_handler) {
    return src.listen(type, listener, opt_capt, opt_handler);
  };
  var unlistenFn = function(src, type, listener, opt_capt, opt_handler) {
    return src.unlisten(type, listener, opt_capt, opt_handler);
  };
  var unlistenByKeyFn = function(src, key) {
    return src.unlistenByKey(key);
  };
  var listenOnceFn = function(src, type, listener, opt_capt, opt_handler) {
    return src.listenOnce(type, listener, opt_capt, opt_handler);
  };
  var dispatchEventFn = function(src, e) {
    return src.dispatchEvent(e);
  };
  var removeAllFn = function(src, opt_type, opt_capture) {
    return src.removeAllListeners(opt_type, opt_capture);
  };
  var getListenersFn = function(src, type, capture) {
    return src.getListeners(type, capture);
  };
  var getListenerFn = function(src, type, listener, capture, opt_handler) {
    return src.getListener(type, listener, capture, opt_handler);
  };
  var hasListenerFn = function(src, opt_type, opt_capture) {
    return src.hasListener(opt_type, opt_capture);
  };

  goog.events.eventTargetTester.setUp(
      newListenableFn, listenFn, unlistenFn, unlistenByKeyFn,
      listenOnceFn, dispatchEventFn,
      removeAllFn, getListenersFn, getListenerFn, hasListenerFn,
      goog.events.eventTargetTester.KeyType.NUMBER,
      goog.events.eventTargetTester.UnlistenReturnType.BOOLEAN, false);
}

function tearDown() {
  goog.events.eventTargetTester.tearDown();
}

function testRuntimeTypeIsCorrect() {
  var target = new goog.events.EventTarget();
  assertTrue(goog.events.Listenable.isImplementedBy(target));
}
</script>
</body>
</html>
